From 6779cb6602c384a4db0a211d1edd25ead7b35bf3 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 19 Apr 2005 13:48:05 +0000 Subject: [PATCH] bitkeeper revision 1.1327 (42650c157OdzpVLoIU2uHsYHltTfYg) Remove unused VERIFY_READ and VERIFY_WRITE parameters from the access_ok, user-space memory check macros. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 8 ++++---- xen/arch/x86/traps.c | 8 ++++---- xen/arch/x86/x86_32/usercopy.c | 6 +++--- xen/arch/x86/x86_64/usercopy.c | 6 +++--- xen/common/dom_mem_ops.c | 8 ++++---- xen/common/grant_table.c | 4 ++-- xen/common/multicall.c | 3 +-- xen/common/physdev.c | 2 +- xen/include/asm-x86/x86_32/uaccess.h | 9 +++------ xen/include/asm-x86/x86_64/uaccess.h | 7 ++----- 10 files changed, 27 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 4bfe7bacd2..2b8f813920 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1464,7 +1464,7 @@ int do_mmuext_op( goto out; } - if ( unlikely(!array_access_ok(VERIFY_READ, uops, count, sizeof(op))) ) + if ( unlikely(!array_access_ok(uops, count, sizeof(op))) ) { rc = -EFAULT; goto out; @@ -1644,7 +1644,7 @@ int do_mmuext_op( unsigned long ents = op.nr_ents; if ( ((ptr & (PAGE_SIZE-1)) != 0) || (ents > 8192) || - !array_access_ok(VERIFY_READ, ptr, ents, LDT_ENTRY_SIZE) ) + !array_access_ok(ptr, ents, LDT_ENTRY_SIZE) ) { okay = 0; MEM_LOG("Bad args to SET_LDT: ptr=%p, ents=%p", ptr, ents); @@ -1819,7 +1819,7 @@ int do_mmu_update( perfc_addc(num_page_updates, count); perfc_incr_histo(bpt_updates, count, PT_UPDATES); - if ( unlikely(!array_access_ok(VERIFY_READ, ureqs, count, sizeof(req))) ) + if ( unlikely(!array_access_ok(ureqs, count, sizeof(req))) ) { rc = -EFAULT; goto out; @@ -2591,7 +2591,7 @@ static int ptwr_emulated_update( struct domain *d = current->domain; /* Aligned access only, thank you. */ - if ( !access_ok(VERIFY_WRITE, addr, bytes) || ((addr & (bytes-1)) != 0) ) + if ( !access_ok(addr, bytes) || ((addr & (bytes-1)) != 0) ) { MEM_LOG("ptwr_emulate: Unaligned or bad size ptwr access (%d, %p)\n", bytes, addr); diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 39a93641ef..b819a79f49 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1105,25 +1105,25 @@ long set_debugreg(struct exec_domain *p, int reg, unsigned long value) switch ( reg ) { case 0: - if ( !access_ok(VERIFY_READ, value, sizeof(long)) ) + if ( !access_ok(value, sizeof(long)) ) return -EPERM; if ( p == current ) __asm__ ( "mov %0, %%db0" : : "r" (value) ); break; case 1: - if ( !access_ok(VERIFY_READ, value, sizeof(long)) ) + if ( !access_ok(value, sizeof(long)) ) return -EPERM; if ( p == current ) __asm__ ( "mov %0, %%db1" : : "r" (value) ); break; case 2: - if ( !access_ok(VERIFY_READ, value, sizeof(long)) ) + if ( !access_ok(value, sizeof(long)) ) return -EPERM; if ( p == current ) __asm__ ( "mov %0, %%db2" : : "r" (value) ); break; case 3: - if ( !access_ok(VERIFY_READ, value, sizeof(long)) ) + if ( !access_ok(value, sizeof(long)) ) return -EPERM; if ( p == current ) __asm__ ( "mov %0, %%db3" : : "r" (value) ); diff --git a/xen/arch/x86/x86_32/usercopy.c b/xen/arch/x86/x86_32/usercopy.c index 7e479bbee8..f26d916bab 100644 --- a/xen/arch/x86/x86_32/usercopy.c +++ b/xen/arch/x86/x86_32/usercopy.c @@ -59,7 +59,7 @@ do { \ unsigned long clear_user(void __user *to, unsigned long n) { - if (access_ok(VERIFY_WRITE, to, n)) + if (access_ok(to, n)) __do_clear_user(to, n); return n; } @@ -410,7 +410,7 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned long n) unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { - if (access_ok(VERIFY_WRITE, to, n)) + if (access_ok(to, n)) n = __copy_to_user(to, from, n); return n; } @@ -434,7 +434,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n) unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) { - if (access_ok(VERIFY_READ, from, n)) + if (access_ok(from, n)) n = __copy_from_user(to, from, n); else memset(to, 0, n); diff --git a/xen/arch/x86/x86_64/usercopy.c b/xen/arch/x86/x86_64/usercopy.c index 839d2582a5..547cacc91b 100644 --- a/xen/arch/x86/x86_64/usercopy.c +++ b/xen/arch/x86/x86_64/usercopy.c @@ -127,7 +127,7 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned n) unsigned long clear_user(void *to, unsigned long n) { - if (access_ok(VERIFY_WRITE, to, n)) + if (access_ok(to, n)) return __clear_user(to, n); return n; } @@ -148,7 +148,7 @@ unsigned long clear_user(void *to, unsigned long n) unsigned long copy_to_user(void __user *to, const void *from, unsigned n) { - if (access_ok(VERIFY_WRITE, to, n)) + if (access_ok(to, n)) n = __copy_to_user(to, from, n); return n; } @@ -172,7 +172,7 @@ copy_to_user(void __user *to, const void *from, unsigned n) unsigned long copy_from_user(void *to, const void __user *from, unsigned n) { - if (access_ok(VERIFY_READ, from, n)) + if (access_ok(from, n)) n = __copy_from_user(to, from, n); else memset(to, 0, n); diff --git a/xen/common/dom_mem_ops.c b/xen/common/dom_mem_ops.c index e8e3b7b256..3d55f4b8af 100644 --- a/xen/common/dom_mem_ops.c +++ b/xen/common/dom_mem_ops.c @@ -41,8 +41,8 @@ alloc_dom_mem(struct domain *d, struct pfn_info *page; unsigned long i; - if ( unlikely(!array_access_ok(VERIFY_WRITE, extent_list, - nr_extents, sizeof(*extent_list))) ) + if ( unlikely(!array_access_ok(extent_list, nr_extents, + sizeof(*extent_list))) ) return start_extent; if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) ) @@ -79,8 +79,8 @@ free_dom_mem(struct domain *d, struct pfn_info *page; unsigned long i, j, mpfn; - if ( unlikely(!array_access_ok(VERIFY_READ, extent_list, - nr_extents, sizeof(*extent_list))) ) + if ( unlikely(!array_access_ok(extent_list, nr_extents, + sizeof(*extent_list))) ) return start_extent; for ( i = start_extent; i < nr_extents; i++ ) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 4e2c93c95c..c0c99481e7 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -812,13 +812,13 @@ do_grant_table_op( { case GNTTABOP_map_grant_ref: if ( unlikely(!array_access_ok( - VERIFY_WRITE, uop, count, sizeof(gnttab_map_grant_ref_t))) ) + uop, count, sizeof(gnttab_map_grant_ref_t))) ) goto out; rc = gnttab_map_grant_ref((gnttab_map_grant_ref_t *)uop, count); break; case GNTTABOP_unmap_grant_ref: if ( unlikely(!array_access_ok( - VERIFY_WRITE, uop, count, sizeof(gnttab_unmap_grant_ref_t))) ) + uop, count, sizeof(gnttab_unmap_grant_ref_t))) ) goto out; rc = gnttab_unmap_grant_ref((gnttab_unmap_grant_ref_t *)uop, count); break; diff --git a/xen/common/multicall.c b/xen/common/multicall.c index cbdf20b63e..c6515d7a9b 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -24,8 +24,7 @@ long do_multicall(multicall_entry_t *call_list, unsigned int nr_calls) return -EINVAL; } - if ( unlikely(!array_access_ok(VERIFY_WRITE, call_list, - nr_calls, sizeof(*call_list))) ) + if ( unlikely(!array_access_ok(call_list, nr_calls, sizeof(*call_list))) ) { DPRINTK("Bad memory range %p for %u*%u bytes.\n", call_list, nr_calls, sizeof(*call_list)); diff --git a/xen/common/physdev.c b/xen/common/physdev.c index a1f182e8c8..de3bd331a1 100644 --- a/xen/common/physdev.c +++ b/xen/common/physdev.c @@ -712,7 +712,7 @@ long do_physdev_op(physdev_op_t *uop) case PHYSDEVOP_SET_IOBITMAP: ret = -EINVAL; - if ( !access_ok(VERIFY_READ, op.u.set_iobitmap.bitmap, IOBMP_BYTES) || + if ( !access_ok(op.u.set_iobitmap.bitmap, IOBMP_BYTES) || (op.u.set_iobitmap.nr_ports > 65536) ) break; ret = 0; diff --git a/xen/include/asm-x86/x86_32/uaccess.h b/xen/include/asm-x86/x86_32/uaccess.h index c875666d65..c3e129d785 100644 --- a/xen/include/asm-x86/x86_32/uaccess.h +++ b/xen/include/asm-x86/x86_32/uaccess.h @@ -11,9 +11,6 @@ #define __user -#define VERIFY_READ 0 -#define VERIFY_WRITE 1 - /* * movsl can be slow when source and dest are not both 8-byte aligned */ @@ -39,10 +36,10 @@ extern struct movsl_mask { :"1" (addr),"g" ((int)(size)),"r" (HYPERVISOR_VIRT_START)); \ flag; }) -#define access_ok(type,addr,size) (likely(__range_not_ok(addr,size) == 0)) +#define access_ok(addr,size) (likely(__range_not_ok(addr,size) == 0)) -#define array_access_ok(type,addr,count,size) \ - (likely(count < (~0UL/size)) && access_ok(type,addr,count*size)) +#define array_access_ok(addr,count,size) \ + (likely(count < (~0UL/size)) && access_ok(addr,count*size)) extern long __get_user_bad(void); extern void __put_user_bad(void); diff --git a/xen/include/asm-x86/x86_64/uaccess.h b/xen/include/asm-x86/x86_64/uaccess.h index bb23ae81a4..d655e01f83 100644 --- a/xen/include/asm-x86/x86_64/uaccess.h +++ b/xen/include/asm-x86/x86_64/uaccess.h @@ -12,9 +12,6 @@ #define __user -#define VERIFY_READ 0 -#define VERIFY_WRITE 1 - /* * Valid if in +ve half of 48-bit address space, or above Xen-reserved area. * This is also valid for range checks (addr, addr+size). As long as the @@ -25,9 +22,9 @@ (((unsigned long)(addr) < (1UL<<48)) || \ ((unsigned long)(addr) >= HYPERVISOR_VIRT_END)) -#define access_ok(type, addr, size) (__addr_ok(addr)) +#define access_ok(addr, size) (__addr_ok(addr)) -#define array_access_ok(type,addr,count,size) (__addr_ok(addr)) +#define array_access_ok(addr, count, size) (__addr_ok(addr)) extern long __get_user_bad(void); extern void __put_user_bad(void); -- 2.30.2